﻿Imports System.ComponentModel
Imports t4mfg.App

Public Class appBackGroundWorker
    Inherits BackgroundWorker
    Public Event WorkIsDone(ByVal sender As Object, ByVal e As EventArgs)
    Dim workerdel As WorkerSubDel
    Dim _writeMessage As frmSplash
    Dim _tb As TextBox
    Private _newText As String
    Public Property NewText() As String
        Get
            Return _newText
        End Get
        Set(ByVal value As String)
            _newText = value
        End Set
    End Property

    Public Sub New(ByVal del As WorkerSubDel, ByVal writeMessage As iWriteTextMessage)
        MyBase.New()
        Me.WorkerSupportsCancellation = True
        Me.WorkerReportsProgress = True
        _writeMessage = writeMessage
        workerdel = del
    End Sub
    Public Sub New()
    End Sub

    Private Sub appBackGroundWorker_DoWork(sender As Object, e As DoWorkEventArgs) Handles Me.DoWork
        workerdel(Me, New EventArgs)
    End Sub

    Private Sub appBackGroundWorker_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles Me.ProgressChanged
        _writeMessage.WriteTextMessage(_newText)
    End Sub

    Private Sub appBackGroundWorker_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles Me.RunWorkerCompleted
        _writeMessage.WriteTextMessage(_newText)
        _writeMessage.Close()
        _writeMessage = Nothing
        RaiseEvent WorkIsDone(Me, New EventArgs)
    End Sub
End Class
